import unittest,requests
from ddt import ddt, file_data

@ddt()
class add_a3mall(unittest.TestCase):
    token=None
    def test_01(self):
        login = requests.post(
            url='http://10.59.9.14:7003/api/public/login',
            json={"username":"15523615759","password":"123456Aa"}
        )
        print(login.json())
        add_a3mall.token = login.json()['data']['token']
        print(add_a3mall.token)

    @file_data('add.json')
    def test_add(self, id, num):
        add = requests.post(
            url='http://10.59.9.14:7003/api/cart/add',
            headers={'Auth-Token': 'Bearer ' + add_a3mall.token},
            json={"id":id,"sku_id":"","num":num}
        )
